home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / CursorCtl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-18  |  6.1 KB  |  150 lines  |  [TEXT/MPS ]

  1. /*---------------------------------------------------------------------------*
  2.  |                                                                           |
  3.  |              <<< CursorCtl.h - Cursor Control Header File >>>             |
  4.  |                                                                           |
  5.  |                               Ira L. Ruben                                |
  6.  |                                 07/27/87                                  |
  7.  |                                                                           |
  8.  |                  Copyright Apple Computer, Inc. 1984-1989, 1994           |
  9.  |                           All rights reserved.                            |
  10.  |                                                                           |
  11.  |        "Beach ball" cursor designed by Fred Forsman and Ira L. Ruben      |
  12.  |                                                                           |
  13.  *---------------------------------------------------------------------------*/
  14.  
  15. /* This file contains:
  16.  
  17. InitCursorCtl(newCursors)        -    Init CursorCtl to load the 'acur' resource
  18. RotateCursor(counter)                -    Sequence through cursor frames for counter mod 32
  19. SpinCursor(increment)                - Sequence mod 32 incrementing internal counter
  20. Hide_Cursor()                                - Hide the current cursor
  21. Show_Cursor(cursorKind)            - Show the cursor
  22.  
  23. */
  24.  
  25. #ifndef __CURSORCTL__
  26. #define __CURSORCTL__
  27.  
  28. enum {
  29.     HIDDEN_CURSOR,
  30.     I_BEAM_CURSOR,
  31.     CROSS_CURSOR,
  32.     PLUS_CURSOR,
  33.     WATCH_CURSOR,
  34.     ARROW_CURSOR
  35. };
  36.  
  37. typedef unsigned char Cursors;
  38.  
  39. #if defined(powerc) || defined(__powerc)
  40. #pragma options align=mac68k
  41. #endif
  42. struct Acur {
  43.     short                        n;
  44.     short                        index;
  45.     short                        frame1;
  46.     short                        fill1;
  47.     short                        frame2;
  48.     short                        fill2;
  49.     short                        frameN;
  50.     short                        fillN;
  51. };
  52. #if defined(powerc) || defined(__powerc)
  53. #pragma options align=reset
  54. #endif
  55.  
  56. typedef struct Acur acur, *acurPtr, **acurHandle;
  57.  
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61.  
  62. pascal void InitCursorCtl(acurHandle newCursors);
  63.     /*
  64.     Initialize the CursorCtl unit. This should be called once prior to calling
  65.     RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  66.     Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  67.     'acur' resource and the 'CURS' resources specified by the 'acur' resource
  68.     ids.  If any of the resources cannot be loaded, the cursor will not be
  69.     changed.
  70.     
  71.     The 'acur' resource is assumed to either be in the currently running tool or
  72.     application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  73.     resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  74.     the System file.
  75.     
  76.     If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  77.     resource designated by the caller and it will be used instead of doing a
  78.     GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  79.     calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  80.     the user the first time it is called.  However, the possible disadvantage of
  81.     using this technique is that the resource memory allocated may have
  82.     undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  83.     has the advantage of causing the allocation at a specific time determined by
  84.     the user.
  85.     
  86.     Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.  Specifically,
  87.     it changes each FrameN/fillN integer pair to a handle to the corresponding
  88.     'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  89.     InitCursorCtl is called, the caller must guarantee NewCursors always points to
  90.     a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  91.     caller who wants to repeatly use multiple 'acur' resources during execution of
  92.     their programs.
  93.     */
  94.  
  95.  
  96. pascal void RotateCursor(long counter);
  97.     /*
  98.     RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  99.     animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  100.     ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  101.     or decrementing index maintained by the caller). A positive counter sequences
  102.     forward through the cursors (e.g., it rotates the "beach ball" cursor
  103.     clockwise), and a negative cursor sequences through the cursors backwards
  104.     (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  105.     RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  106.   It is assumed the cursor is visible from a prior Show_Cursor call.
  107.     */
  108.  
  109.  
  110. pascal void SpinCursor(short increment);
  111.     /*
  112.     SpinCursor is similar in function to RotateCursor, except that instead of
  113.     passing a counter, an Increment is passed an added to a counter maintained
  114.     here.  SpinCursor is provided for those users who do not happen to have a
  115.     convenient counter handy but still want to use the spinning "beach ball"
  116.     cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  117.     increment sequences forward through the curos (rotating the "beach ball"
  118.     cursor clockwise), and a negative increment sequences backward through the
  119.     cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  120.     for the increment resets the counter to zero.  Note, it is the increment, and
  121.     not the value of the counter that determines the sequencing direction of the
  122.     cursor (and hence the spin direction of the "beach ball" cursor).
  123.     */
  124.  
  125.         
  126. pascal void Hide_Cursor(void);
  127.     /*
  128.     Hide the cursor if it is showing.    This is this unit's call to the Mac
  129.     HideCursor routine.    Thus the Mac cursor level is decremented by one when this
  130.     routine is called.
  131.     */
  132.  
  133.  
  134. pascal void  Show_Cursor(Cursors cursorKind);
  135.     /*
  136.     Increment the cursor level, which may have been decremented by Hide_Cursor,
  137.     and display the specified cursor if the level becomes 0 (it is never
  138.     incremented beyond 0).    The CursorKind is the kind of cursor to show.  It is
  139.     one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  140.     WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is 
  141.     done for the specified cursor prior to doing a ShowCursor.  HIDDEN_CURSOR just
  142.     causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  143.     there is already a grafPort set up pointed to by 0(A5).
  144.     */
  145.  
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif
  150.